package com.xls.box2023.adapter;

import android.app.Activity;
import android.content.Context;
import android.view.ViewGroup;

import com.lzz.bottomencapsulation.adapter.MvpBaseRecyclerAdapter;
import com.xls.box2023.entity.YouXiEntity;
import com.xls.box2023.manager.APKDownLoadEntity;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;

/**
 * 首页---游戏列表适配器
 */
public class YouXiListAdapter extends MvpBaseRecyclerAdapter<YouXiItemViewHolder> {
    ArrayList<YouXiEntity> dataList=null;
    Activity activity;

    public YouXiListAdapter(Activity context, ArrayList<YouXiEntity> dataList) {
        super(context);
        this.activity=context;
        this.dataList = dataList;
    }

    public YouXiListAdapter(Context context, OnItemClickListener onItemClickListener, ArrayList<YouXiEntity> dataList, Activity activity) {
        super(context, onItemClickListener);
        this.dataList = dataList;
        this.activity = activity;
    }


    @Override
    public void onBindView(@NonNull YouXiItemViewHolder holder, int position) {
        holder.setViewData(dataList.get(position));
        holder.initView();
    }

    @Override
    public void onBindView(YouXiItemViewHolder holder, int position, List<Object> payloads) {
        if (payloads!=null){
            APKDownLoadEntity youXiEntity=((APKDownLoadEntity) payloads.get(0));
            holder.refishState(youXiEntity);
        }
    }

    @NonNull
    @Override
    public YouXiItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new YouXiItemViewHolder(activity,parent);
    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }
}
